//
//  JGRealTimeOrderCell.m
//  JGRider
//
//  Created by 单启志 on 2018/2/28.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGRealTimeOrderCell.h"
@interface JGRealTimeOrderCell()
@property (weak, nonatomic) IBOutlet UILabel *fromDistanceLab;//取单路程
@property (weak, nonatomic) IBOutlet UILabel *toDistanceLab;//送单路程
@property (weak, nonatomic) IBOutlet UILabel *orderNubLab; //订单号
@property (weak, nonatomic) IBOutlet UILabel *fromAddressLab;//取单地址
@property (weak, nonatomic) IBOutlet UILabel *toAddressLab;//送单地址
@property (weak, nonatomic) IBOutlet UILabel *distributionTimeLab;//配送时间范围
@property (weak, nonatomic) IBOutlet UIButton *placeOrderBtn;//抢单

@end
@implementation JGRealTimeOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self layoutSubViews];
}

-(void)layoutSubViews{

    self.selectionStyle=UITableViewCellSelectionStyleNone;
    self.distributionTimeLab.layer.cornerRadius=AdaptedHeight(20)/2;
    self.distributionTimeLab.layer.masksToBounds=YES;
    self.distributionTimeLab.layer.borderWidth=AdaptedWidth(0.5);
    self.distributionTimeLab.layer.borderColor=HEXCOLOR(0x577ef4).CGColor;

    self.placeOrderBtn.layer.cornerRadius=AdaptedWidth(2);
    self.placeOrderBtn.layer.masksToBounds=YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setFrame:(CGRect)frame{
    frame.origin.y+=AdaptedWidth(5);
    frame.size.height-=AdaptedWidth(5);
    [super setFrame:frame];
}

//抢单
- (IBAction)onPlaceOrderBtnClick:(id)sender {

    if ([self.delegate respondsToSelector:@selector(cellPlaceOrderEvent:)]) {
        [self.delegate cellPlaceOrderEvent:self];
    }

}


-(void)setModel:(JGRealTimeOrderModel *)model{
    _model=model;

    NSString *formAddress=[NSString stringWithFormat:@"取：%@",model.sellerAddress];
    NSString *toAddress=[NSString stringWithFormat:@"送：%@",model.receiveAddress];

    self.fromAddressLab.text=formAddress;
    self.toAddressLab.text=toAddress;
    self.distributionTimeLab.text=model.postTime;

    self.orderNubLab.text=[NSString stringWithFormat:@"%ld",model.Id];

}

@end
